姓名:王闯

学号:4201381

In [1]:
f = open('作业一素材.txt',encoding='utf-8')
txt = f.read()
f.close()

index = txt.find('\n顺丰控股股份有限公司')

txt_target = txt[:index]
lines = txt_target.split('\n')
last_line = lines[-1]
words = last_line.split(' ')
last_word = words[-1]

for i in range(1,len(last_word)):
    last_character = last_word[-i]
    if last_character.isalpha():
        last_word = last_word[:-i+1]
        break

if i == len(last_word):
    last_word = words[-2]

print(last_word)
period